/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSky.producer.builder;

import ru.jSky.interfaces.support.Unmodifiable;
import ru.jSky.producer.DwindleProducer;
import ru.jSky.producer.Producer;
import ru.jSky.producer.CompositeProducer;

/**
 *
 * @author Rakev
 */
public abstract class CompositeProducerBuilder<F, C> implements ProducerBuilder<F, C>, Unmodifiable {

    private Producer<F, C> upProducer;

    public CompositeProducerBuilder(Producer<F, C> producer) {
        this.upProducer = producer;
    }

    @Override
    public Producer<F, C> build() {
        return getUpProducer();
    }

    protected <T> Producer<F, T> build(Producer<C, T> lastProducer) {
        return new CompositeProducer<>(getUpProducer(), lastProducer);
    }

    private Producer<F, C> getUpProducer() {
        return upProducer;
    }
}
